package com.jic.manager.impl;

import java.lang.Long;
import java.util.List;

import com.jic.manager.entity.MerchantWeBankSalesArea;
import com.jic.manager.mapper.MerchantWeBankSalesAreaMapper;
import com.jic.manager.service.MerchantWeBankSalesAreaService;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.Page;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 商户销售区域表
 * @author : 
 * @email : 
 * @since : 2020-11-28 11:08:22
 * @version : v1.0.0
 */
@Service
public class MerchantWeBankSalesAreaServiceImpl implements MerchantWeBankSalesAreaService{

    @Autowired
    private MerchantWeBankSalesAreaMapper merchantWeBankSalesAreaMapper;

    @Override
    public long insert(MerchantWeBankSalesArea merchantWeBankSalesArea) {
        long flag = merchantWeBankSalesAreaMapper.insert(merchantWeBankSalesArea);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return merchantWeBankSalesAreaMapper.delete(id);
    }

    @Override
    public long update(MerchantWeBankSalesArea merchantWeBankSalesArea) {
        return merchantWeBankSalesAreaMapper.update(merchantWeBankSalesArea);
    }

    @Override
    public MerchantWeBankSalesArea queryByPrimaryKey(Long id){
        return merchantWeBankSalesAreaMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<MerchantWeBankSalesArea> query(MerchantWeBankSalesArea merchantWeBankSalesArea){
        return merchantWeBankSalesAreaMapper.query(merchantWeBankSalesArea);
    }

    @Override
    public PageResult<MerchantWeBankSalesArea> queryPage(MerchantWeBankSalesArea merchantWeBankSalesArea, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<MerchantWeBankSalesArea> list = merchantWeBankSalesAreaMapper.queryPage(startIndex, pageQuery.getLimit(), merchantWeBankSalesArea);
        long count = merchantWeBankSalesAreaMapper.queryPageCount(merchantWeBankSalesArea);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}